package app.android.kdictionary.Component;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.Button;
import app.android.kdictionary.data.RefInt;

public class SearchSelectRadioDialog extends AlertDialog.Builder {
	private RefInt mSelectItem;
	private String mItems[];
	private Button mSelectButton;
	
	public SearchSelectRadioDialog(Context context, String items[], RefInt selectItem, Button selectButton) {
		super(context);
		
		mItems = items;
		mSelectItem = selectItem;
		mSelectButton = selectButton;
		
		this.setSingleChoiceItems(mItems, 0, radio_listener);
	}

	private DialogInterface.OnClickListener radio_listener = new DialogInterface.OnClickListener() {
		public void onClick(DialogInterface dialog, int item) {
	        mSelectItem.setValue(item);
			mSelectButton.setText(mItems[item]);	        
	        dialog.dismiss();
	    }
	};
}
